cmake_minimum_required (VERSION 2.6)

PROJECT(BubblesOS CXX C)

set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

set(KINCLUDES "-I. -I${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/lib/plosdk/core -I${CMAKE_SOURCE_DIR}/lib/plosdk/exception -I${CMAKE_SOURCE_DIR}/lib/stdc/include -I${CMAKE_SOURCE_DIR}/lib/stdcxx/include")
SET(KINCLUDES "${KINCLUDES} -DPLCOREEXPORT")

SET(LIB_PLSDK_CORE_KERNEL_SRC
	kernel/PLGlobal.h
	kernel/PLExceptionFactory.cpp
	kernel/PLExceptionFactory.h
	kernel/PLExceptionFactoryElement.cpp
	kernel/PLExceptionFactoryElement.h
	kernel/PLExceptionHash.cpp
	kernel/PLExceptionHash.h
	kernel/PLClassIdFactory.cpp
	kernel/PLClassIdFactory.h
	kernel/PLCStringHash.cpp
	kernel/PLCStringHash.h
	kernel/PLObject.cpp
	kernel/PLObject.h
    kernel/PLOSDefines.h
    kernel/PLTypes.h
	kernel/signalslot/PLSignalSlot.h
	kernel/signalslot/lang/PLConnection0.h
	kernel/signalslot/lang/PLConnection1.h
	kernel/signalslot/lang/PLConnection2.h
	kernel/signalslot/lang/PLConnection3.h
	kernel/signalslot/lang/PLConnection4.h
	kernel/signalslot/lang/PLConnection5.h
	kernel/signalslot/lang/PLConnection6.h
	kernel/signalslot/lang/PLConnection7.h
	kernel/signalslot/lang/PLConnection8.h
	kernel/signalslot/lang/PLConnection9.h
	kernel/signalslot/lang/PLConnection10.h
	kernel/signalslot/lang/PLConnectionBase.h
	kernel/signalslot/lang/PLConnectionData.cpp
	kernel/signalslot/lang/PLConnectionData.h
	kernel/signalslot/lang/PLSignalTypes.h
	kernel/signalslot/lang/PLSignalBase.cpp
	kernel/signalslot/lang/PLSignalBase.h
	kernel/signalslot/lang/PLISignalBase0.h
	kernel/signalslot/lang/PLISignalBase1.h
	kernel/signalslot/lang/PLISignalBase2.h
	kernel/signalslot/lang/PLISignalBase3.h
	kernel/signalslot/lang/PLISignalBase4.h
	kernel/signalslot/lang/PLISignalBase5.h
	kernel/signalslot/lang/PLISignalBase6.h
	kernel/signalslot/lang/PLISignalBase7.h
	kernel/signalslot/lang/PLISignalBase8.h
	kernel/signalslot/lang/PLISignalBase9.h
	kernel/signalslot/lang/PLISignalBase10.h
	kernel/signalslot/lang/PLSignal0.h
	kernel/signalslot/lang/PLSignal1.h
	kernel/signalslot/lang/PLSignal2.h
	kernel/signalslot/lang/PLSignal3.h
)

SET(LIB_PLSDK_KERNEL_LANG_SRC
    kernel/lang/PLHash.h
    kernel/lang/PLHash.cpp
    kernel/lang/PLIHash.h
)

SET(LIB_PLSDK_CORE_TOOLS_SRC
	tools/PLFlags.h
	tools/PLSingleton.h
	tools/PLArray.h
	tools/PLCharArray.h
	tools/PLVector.h
    tools/PLHashTable.h
    tools/PLIEnumerator.h
    tools/PLHashTableKeyEnumerator.h
    tools/PLHashTableEnumerator.h
    tools/PLCharBuffer.h
    tools/PLBuffer.h
    tools/PLRadixTreeVoid.cpp
    tools/PLRadixTreeVoid.h
    tools/PLRadixTreeNode.cpp
    tools/PLRadixTreeNode.h
    tools/PLRadixTree.h
    tools/PLIIterator.h
    tools/PLIterator.h
    tools/PLILinkedListIterator.h
    tools/PLIListIterator.h
    tools/PLLinkedList.h
    tools/PLLinkedListIterator.h
    tools/PLLinkedListNode.h
    tools/PLList.h
    tools/PLListIterator.h
    tools/PLListNode.h
    tools/PLRingList.h
    tools/PLStack.h
)

SET(LIB_PLSDK_CORE_ELF_SRC
	elf/plelf.h
	elf/plelf32.h
	elf/plelf32.cpp
	elf/plelf64.h
	elf/plelf64.cpp
	elf/plelfapplicationheader32.h
	elf/plelfapplicationheader64.h
	elf/plelfapplicationheaderenums.h
	elf/plelfbase.cpp
	elf/plelfbase.h
	elf/plelfheader32.cpp
	elf/plelfheader32.h
	elf/plelfheader64.cpp
	elf/plelfheader64.h
	elf/plelfheaderenums.cpp
	elf/plelfheaderenums.h
	elf/plelfidentification.h
	elf/plelfrelocation32.h
	elf/plelfrelocation64.h
	elf/plelfrelocationa32.h
	elf/plelfrelocationa64.h
	elf/plelfsectionheader32.h
	elf/plelfsectionheader64.h
	elf/plelfsectionheaderenums.h
	elf/plelfsectionheaderenums.cpp
	elf/plelfstddef.h
	elf/plelfstringtable.cpp
	elf/plelfstringtable.h
	elf/plelfsymboltable32.h
	elf/plelfsymboltable64.h
	elf/plelfsymboltableenum.h
    elf/plelfsymbol32.h
    elf/plelfsymbol64.h
)

SET(LIB_PLSDK_CORE_EXCEPTION_SRC
	exception/PLException.cpp
	exception/PLException.h
	exception/PLElementNotFoundException.cpp
	exception/PLElementNotFoundException.h
	exception/PLIndexOutOfRangeException.cpp
	exception/PLIndexOutOfRangeException.h
)

SET(LIB_PLSDK_CORE_SRC
	${LIB_PLSDK_CORE_KERNEL_SRC}
    ${LIB_PLSDK_KERNEL_LANG_SRC}
	${LIB_PLSDK_CORE_TOOLS_SRC}
	${LIB_PLSDK_CORE_ELF_SRC}
	${LIB_PLSDK_CORE_EXCEPTION_SRC}
)

add_library( liboplsdkcore STATIC
	${LIB_PLSDK_CORE_SRC}
)

#add_library( plosdkcore SHARED
#	${LIB_PLSDK_CORE_SRC}
#)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/kernel/PLAPIConfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/kernel/PLAPIConfig.h)

SET(CMAKE_CXX_COMPILE_OBJECT "${gplusplus} ${KFLAGS} ${WFLAGS} ${OPTIMIZEFLAGS} ${KINCLUDES} -g3 -c -o <OBJECT> <SOURCE>")
SET(CMAKE_C_COMPILE_OBJECT "${gcc} ${KCFLAGS} ${WFLAGS} ${OPTIMIZEFLAGS} ${KINCLUDES} -g3 -c -o <OBJECT> <SOURCE>")
SET(CMAKE_AR "${gar}")
SET(CMAKE_RANLIB "${granlib}")
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
SET(CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
SET(CMAKE_CXX_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND})
SET(CMAKE_CXX_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH})
